package com.zxcl.config;

import cn.hutool.core.lang.Snowflake;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述: [ID生成工具]
 * 作者: 雷哥(LEO)
 * 邮箱: 78414842@qq.com
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@RefreshScope
@Configuration
public class IdConfig {
    @Value("${id.workerId}")
    private Long workId;
    @Value("${id.dataCenterId}")
    private Long dataCenterId;
    @Bean
    public Snowflake snowflake(){
        return  new Snowflake(workId,dataCenterId);
    }
}
